package com.ving.test;

import com.ving.test.mybatis01.Configuration01;
import com.ving.test.mybatis01.session.SqlSession01;
import com.ving.test.mybatis01.session.SqlSessionFactory01;
import com.ving.test.mybatis01.session.SqlSessionFactoryBuilder01;
import com.ving.test.mybatis02.session.Configuration02;
import com.ving.test.mybatis02.session.DefaultSqlSession02;
import com.ving.test.mybatis02.session.SqlSessionFactory02;
import com.ving.test.mybatis02.session.SqlSessionFactoryBuilder02;
import com.ving.test.nativemybatis.entity.TestBean;
import com.ving.test.nativemybatis.mapper.TestMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.io.Resources;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.junit.Test;
import sun.java2d.xr.XRRenderer;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by liuweijie on 2019-11-14.
 */
@Slf4j
public class VingMybatisTest02 {

    @Test
    public void test01() {
      String path = "mybatis02/vingmybatis-config02.xml";
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream(path);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Configuration02 conf = new Configuration02(inputStream);
        SqlSessionFactory02 sqlSessionFactory02 = new SqlSessionFactoryBuilder02().build(conf);
        DefaultSqlSession02 sqlSession = sqlSessionFactory02.openSession(conf);
        TestMapper mapper = sqlSession.getMapper(TestMapper.class);
        TestBean testBean = mapper.selectUser(4);
        System.out.println(testBean);
    }

}
